<?php
return [
    /**
     * 后台表单采用默认自动生成时的设置
     */
    'form' => [
        'id'    => [
            'display' => 'ID'
        ],
        'name'  => [
            'text' => '登录名',
            'creationRules' => ['required', "unique:users"],
            'updateRules' => ['required', "unique:users,name,{{id}}"],
            'required'    => null
        ],
        'username' => [
            'text' => '呢称',
            'creationRules' => ['required', "unique:users"],
            'updateRules' => ['required', "unique:users,username,{{id}}"],
            'required'    => null
        ],
        'email' => [
            'email' => '邮箱',
            'creationRules' => ['required', "unique:users"],
            'updateRules' => ['required', "unique:users,email,{{id}}"],
            'required'    => null
        ],
        'phone' => [
            'mobile' => '手机',
            'creationRules' => ['required', "unique:users"],
            'updateRules' => ['required', "unique:users,phone,{{id}}"],
            'required'    => null,
            'options' => ['mask' => '999 9999 9999']
        ],
        'avatar' => [
            'image' => '头像',
        ],
        'password' => [
            'password' => '密码',
            'rules'     => 'required|confirmed',
        ],
        'password_confirmation' => [
            'password' => '重复密码',
            'rules'     => 'required'
        ],
        'created_at'    => [
            'display' => '注册日期'
        ],
        'updated_at'    => [
            'display' => '活动日期'
        ],
        //附加的设置用数字表示
        '0'  => [
            'ignore' => ['password_confirmation'],
        ],
        '1'    => [
            'saving' => function ($form) {
                if ($form->password && $form->model()->password != $form->password) {
                    $form->password = bcrypt($form->password);
                }
            }
        ],
    ],
    //更新表单时同一字段若有与新建表单不同设置的用以下设置替换
    'form_update_replace' => [
        'name'  => [
            'display' => '登录名',
        ]
    ],
    //新建时忽略字段
    'form_create_ignore' => ['id', 'created_at', 'updated_at',  'remember_token'],
    //修改时忽略
    'form_update_ignore' => [0, 1, 'password', 'password_confirmation', 'created_at', 'updated_at',  'remember_token'],
    //后台index时显示
    'grid_fields' => ['id', 'avatar', 'name', 'username', 'email', 'created_at', 'updated_at'],
    //后台show时显示
    'show_fields' => ['id', 'avatar', 'name', 'username', 'email', 'created_at', 'updated_at'],
];
